Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux: Report reclaimable memory to kernel as such #16385

Merged
merged 1 commit into from
Jul 30, 2024

Conversation

amotin
Copy link
Member

@amotin amotin commented Jul 24, 2024

Linux provides SLAB_RECLAIM_ACCOUNT and __GFP_RECLAIMABLE flags to mark memory allocations that can be freed via shinker calls. It should allow kernel to tune and group such allocations for lower memory fragmentation and better reclamation under pressure.

This patch marks as reclaimable most of ARC memory, directly evictable via ZFS shrinker, plus also dnode/znode/sa memory, indirectly evictable via kernel's superblock shrinker.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

@amotin amotin requested a review from behlendorf July 24, 2024 01:09
Linux provides SLAB_RECLAIM_ACCOUNT and __GFP_RECLAIMABLE flags to
mark memory allocations that can be freed via shinker calls.  It
should allow kernel to tune and group such allocations for lower
memory fragmentation and better reclamation under pressure.

This patch marks as reclaimable most of ARC memory, directly
evictable via ZFS shrinker, plus also dnode/znode/sa memory,
indirectly evictable via kernel's superblock shrinker.

Signed-off-by:	Alexander Motin <[email protected]>
Sponsored by:	iXsystems, Inc.
@tonyhutter tonyhutter added the Status: Code Review Needed Ready for review and testing label Jul 25, 2024
@tonyhutter
Copy link
Contributor

Could we get one more reviewer on this one?

@tonyhutter tonyhutter merged commit d4b5517 into openzfs:master Jul 30, 2024
19 of 25 checks passed
@amotin amotin deleted the reclaimable branch July 30, 2024 18:53
@adamdmoss
Copy link
Contributor

While I think the changes (and goals!) make sense, I don't appear to be able to see a difference in either the kernel's accounting of free/available memory (casually tested via 'free' and similar) or general eviction behavior. Tested (as I said, casually - filling ARC, applying slow or fast memory pressure, applying non-ARC pagecache pressure, etc, eyeing 'free' and other end-user memory stat gatherers) with a Linux 6.8 kernel.

Is there a specific stat or testing pattern where this is clearly functional and beneficial? Thanks.

@amotin
Copy link
Member Author

amotin commented Jul 30, 2024

@adamdmoss SLAB_RECLAIM_ACCOUNT memory should be included into SReclaimable in /proc/meminfo and then into available memory, which as I see should be used by different balloon drivers. __GFP_RECLAIMABLE I haven't found to be reported directly, but I understand it to be grouped together as Reclaimable migration type, as reported in /proc/pagetypeinfo.

@adamdmoss
Copy link
Contributor

Thanks, that makes some sense.
Looks like it's my confusion; for some reason I thought arc contents were slab-allocated, but it appears they're not (according to /proc/meminfo and slabinfo); arc headers and some other metadata are slab-allocated but the contents (mostly held in ABDs I think?) aren't.

lundman pushed a commit to openzfsonwindows/openzfs that referenced this pull request Sep 4, 2024
Linux provides SLAB_RECLAIM_ACCOUNT and __GFP_RECLAIMABLE flags to
mark memory allocations that can be freed via shinker calls.  It
should allow kernel to tune and group such allocations for lower
memory fragmentation and better reclamation under pressure.

This patch marks as reclaimable most of ARC memory, directly
evictable via ZFS shrinker, plus also dnode/znode/sa memory,
indirectly evictable via kernel's superblock shrinker.

Signed-off-by:	Alexander Motin <[email protected]>
Sponsored by:	iXsystems, Inc.
Reviewed-by: Tony Hutter <[email protected]>
Reviewed-by: Allan Jude <[email protected]>
snajpa added a commit to vpsfreecz/zfs that referenced this pull request Oct 16, 2024
snajpa added a commit to vpsfreecz/zfs that referenced this pull request Oct 16, 2024
snajpa added a commit to vpsfreecz/zfs that referenced this pull request Oct 17, 2024
snajpa added a commit to vpsfreecz/zfs that referenced this pull request Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Code Review Needed Ready for review and testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants